Cloning programming code refers to creating various versions of the code, usually in the form of a function, to optimize the function's performance. Generally, one or more versions of a function are created or “cloned” from the function, and each cloned version performs better if a condition is satisfied. During program execution, if the condition corresponding to a cloned function is met, that cloned function, instead of the original function, is invoked, and the program therefore executes better because it runs a better version of the function.
Currently, to identify cloning candidates, the compiler needs to identify the callers and their relevant information, such as context information, values, properties, etc., of the argument, global variables, etc. The compiler also needs to identify the definition or the function body including the programming code of the function to be called (e.g., the callee) so that the compiler can perform analysis to determine the cloning benefits, strategies, etc. The compiler further needs to process the source code of the program and related libraries at the same time.
Additionally, independent cloning for shared libraries that contain functions including their cloned versions cannot be done because when a shared library is built independently from other routines of a program, information related to the calls, the callers, etc., is not available. However, when the program applications invoking the cloned functions are built, information of the callers is available, but the source code of the library may not be available for modification. Building a library or a program refers to creating binary programming code from its source code, including compiling and linking various objects, object modules, etc.
Based on the foregoing, it is desirable that mechanisms be provided to solve the above deficiencies and related problems.